#include<iostream>
#include<string>
using namespace std;
class Base
{public:
    void setTitle()
    {
        cout<<"书名:";
        cin>>title;
    }
    void printTitle(){ cout<<"书名:"<<title<<""; }
    virtual bool isGood()=0;
protected:
    char title[80];
};

class Book:public Base
{public:
    void setSold()
    {
        cout<<"每月销售数量:";
        cin>>numsold;
    }
    bool isGood(){ return(numsold>500)? true:false; }
private:
    int numsold;
};

class Journal:public Base
{public:
    void setSold()
    {
        cout<<"每月销售杂志量:";
        cin>>numsold;
    }
    bool isGood(){ return(numsold>2500)? true:false; }
private:
    int numsold;
};

int main()
{
    Base * p[50];
    Book * pbook;
    Journal * pjour;
    char ch;
    int count=0;
    do
    {	cout<<"输入书(b)或杂志(j):";
        cin>>ch;
        if(ch=='b')
        {
            pbook=new Book;
            pbook->setTitle();
            pbook->setSold();
            p[count++]=pbook;
        }
        else if(ch=='j')
        {
            pjour=new Journal;
            pjour->setTitle();
            pjour->setSold();
            p[count++]=pjour;
        }
        else
            cout<<"输入错误"<<endl;
        cout<<"继续输入吗(y/n)?";
        cin>>ch;
    }while(ch=='y'||ch=='y');
    for(int i=0;i<count;i++)
    {
        p[i]->printTitle();
        if(p[i]->isGood())
            cout<<"销售良好!"<<endl;
        else
            cout<<"销售一般!"<<endl;
    }
    return 0;
}
